<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="./js/jquery-2.1.0.js"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/Global.js"></script>
    <style>
        .wrap {
            padding: 20px;
            width: 100%;
            overflow: auto;
            box-sizing: border-box;
        }

        .select {
            height: 40px;
            padding: 20px 0;
            border-bottom: 1px solid #ccc;
            text-align: center;
        }

        .search {
            width: 200px;
            height: 38px;
            margin: 0 auto;
            display: inline-block;
            padding-top: 1px;

        }

        select {
            height: 36px;
            min-width: 80px;
        }

        .layui-input {
            border: 0;
            outline: none;
        }

        .btn {
            display: inline-block;

        }

        .next {
            text-align: center;
        }

        .layui-table td,
        .layui-table th {
            padding: 0;
            text-align: center;
            height: 36px;
            line-height: 36px;
            font-size: 14px;
        }

        .hanf {
            width: 49%;
        }

        .layui-input-block {
            margin-left: 0px;
            padding: 0 5px;
        }

        .control {
            min-width: 110px;
        }

        .num {
            min-width: 50px;
        }

        .top-nav {
            font-size: 14px;
            list-style: none;
            position: relative;
            display: none;
        }
        .winbody {
            width: 1200px;
            padding: 10px;
            display: none;
        }
    </style>
</head>

<body>
    <div class="wrap">
        <div style="text-align: center;">
            销售出库
        </div>
        <table class="layui-table" lay-filter="table">
            <thead>
                <tr>
                    <th width="5%" class="num">日期</th>
                    <th width="15%">出库单号</th>
                    <th width="10%">来源</th>
                    <th width="10%">去向</th>
                    <th width="7.5%">收款方式</th>
                    <th width="7.5%">承运企业</th>
                    <th width="7.5%">品牌</th>
                    <th width="7.5%">型号</th>
                    <th width="7.5%">产地</th>
                    <th width="7.5%">物料新旧</th>
                    <th width="5%">单位</th>
                    <th width="5%">需求量</th>
                    <th width="5%">业务经理</th>
                </tr>
            </thead>
            <tbody class="lists">

            </tbody>
        </table>
        <div class="winbody">
            <table class="layui-table">
                <thead>
                    <tr>
                        <th>序号</th>
                        <th>客户名称</th>
                        <th>订单日期</th>
                        <th>订单号</th>
                        <th>品名</th>
                        <th>品牌</th>
                        <th>规格</th>
                        <th>型号</th>
                        <th>产地</th>
                        <th>物料新旧</th>
                        <th>单位</th>
                        <th>需求数量</th>
                        <th>库存数量</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody class="chukulist">
                    <tr>
                        <td>1</td>
                        <td>金方舟长客服务中心</td>
                        <td>2018-09-11</td>
                        <td>CGDD180911002</td>
                        <td>电器-定位器</td>
                        <td>胎客</td>
                        <td>固定式</td>
                        <td>TM-CFQ-A</td>
                        <td>国产</td>
                        <td>旧物品</td>
                        <td>桶</td>
                        <td>1</td>
                        <td>0</td>
                        <td>0</td>
                        <td onclick="ckInfo()">销售出库</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</body>
<script>
    // 
    let layer =  ''
    layui.use('layer',function () {
        layer = layui.layer
    })
    function ckList () {
        $.ajax({
            url:`${API}/erpOrderdMateriel/getOrderdMateriel?custId=${loadUserInfo.customer.id}`,
            type:'get',
            success: function (res) {
                let arr = res.data
                let str  = ''
                $.each(arr,function (i,n) {
                    
                    if(n) {
                        str  += `<tr>
                            <td></td>
                            </tr>`
                    }
                })
                layer.open({
                    type:1,
                    content:$('.winbody'),
                    btn:['确定'],
                    title:'订单排列',
                    area:['1240px']
                })
            },
            error:function () {
                alert('系统错误！')
            }
        })
    }
    // 查询
    $.ajax({
        url: `${API}/erpOrderd/getListOrderd`,
        type: 'post',
        data: {
            page: 1,
            limit: 10,
            custId: 1
        },
        success: function (res) {
            $.ajax({
                url: `${API}/erpClients/getClientsAll`,
                type: 'get',
                success: function (res1) {

                    var list = res1.data;
                    let arr = res.data.reverse()
                    let str = ''
                    $.each(arr, function (i, n) {
                        str += `<tr>
                    <td>${arr.length - i}</td>`
                        var name = "";
                        $.each(list, function (j, m) {
                            if (n.customerId == m.id) {
                                name = m.customerName;
                            }
                        });
                        str += `<td>${name}</td>
                    <td>${n.sheetId}</td>
                    <td>JFZ${(new Date().getTime())}${i}</td>
                    `
                        if (n.orderdMateriels != null) {
                            str += `<td>${n.orderdMateriels.materielName == null ? '' : n.orderdMateriels.materielName}</td>
                    <td>${n.orderdMateriels.materielSpecifications == null ? '' : n.orderdMateriels.materielSpecifications}</td>
                    <td>${n.orderdMateriels.materielBrand == null ? '' : n.orderdMateriels.materielBrand}</td>
                    <td>${n.orderdMateriels.materielModel == null ? '' : n.orderdMateriels.materielModel}</td>
                    <td>${n.orderdMateriels.materielPlace == null ? '' : n.orderdMateriels.materielPlace}</td>
                    <td>${n.orderdMateriels.materielState == null ? '' : n.orderdMateriels.materielState}</td>
                    <td>${n.orderdMateriels.materielUnit == null ? '' : n.orderdMateriels.materielUnit}</td>
                    <td>${n.orderdMateriels.materielAmount == null ? '' : n.orderdMateriels.materielAmount}</td>`

                        } else {
                            str += `<td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>`
                        }
                        str += `<td> ${n.bManager == null ? '' : n.bManager}</td >
                    </tr >`
                    })
                    $('.lists').append(str)
                }
            })


        }
    })
</script>